/**
 * Created with hong.rong
 * Description:减少使用 dangerouslySetInnerHTML
 * Date:2020/06/25
 */

import React, { useRef, useEffect } from 'react'
import { yuan } from '../components/Charts'

export default function Yuan({ children }) {
  const yuanRef = useRef()

  useEffect(() => {
    renderToHtml(children)
  }, [children])

  const renderToHtml = children => {
    if (yuanRef.current) {
      yuanRef.current.innerHTML = yuan(children)
    }
  }

  return <span ref={yuanRef} />
}
